.global _start

.global _bss_start
_bss_start:
	.word __bss_start

.global _bss_end
_bss_end:
	.word __bss_end

_start:
	/* svc mode */
	mrs r0, cpsr	@read cpsr
	bic r0, #0x1f	@clear cpsr M[4:0]
	orr r0, #0x13	@set cpsr M[4:0]=0x13, it is svc mode
	msr cpsr, r0
	
	/* clear .bss to zero */
	ldr r0, _bss_start
	ldr r1, _bss_end
	mov r2, #0
bss_loop:
	stmia r0!, {r2}
	cmp r0, r1	@compare r0, r1
	ble bss_loop	@jump to bss_loop if r0 <= r1
	
	/* set SP register */
	ldr sp, =0x80200000
	b main

